package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.DeviceObjectRelateDao;
import cn.topevery.garden.entity.po.DeviceObjectRelate;
import cn.topevery.garden.entity.query.DeviceObjectRelateQuery;
import cn.topevery.garden.entity.query.DeviceObjectResultQuery;
import cn.topevery.garden.entity.vo.DeviceObjectResultVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2021-09-08
 */
@Service
public class DeviceObjectRelateLogic extends BaseLogic<DeviceObjectRelate> {
    @Autowired
    DeviceObjectRelateDao deviceObjectRelateDao;

    @Override
    public BaseEntityDao<DeviceObjectRelate, Integer> getDao() {
        return deviceObjectRelateDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<DeviceObjectRelate> listPage(DeviceObjectRelateQuery query) {
        return deviceObjectRelateDao.listPage(query);
    }

    /**
     * 描述 获取所有列表.
     *
     * @param type the type
     * @return the list
     * @author wenzhao.lin
     * @created 2021 -09-08 14:06:39 Get all list list.
     */
    public List<DeviceObjectRelate> getAllList(Integer type){
        return deviceObjectRelateDao.getAllList(type);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,List<Integer> ids) {
        deviceObjectRelateDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param deviceObjectRelate 实体
     */
    public void saveOrUpdate(String userId, DeviceObjectRelate deviceObjectRelate){
        deviceObjectRelateDao.saveOrUpdate(userId,deviceObjectRelate);
    }

    /**
     * 描述 获取数据列表.
     *
     * @param query the query
     * @return the data pager
     * @author wenzhao.lin
     * @created 2021 -09-08 14:57:48 Get data page data pager.
     */
    public DataPager<DeviceObjectResultVO> getDataPage(DeviceObjectResultQuery query){
        return deviceObjectRelateDao.getDataPage(query);
    }

    /**
     * 描述 检查是否已存在.
     *
     * @param fieldName the field name
     * @param value     the value
     * @return the boolean
     * @author wenzhao.lin
     * @created 2021 -09-08 18:09:19 Is exit boolean.
     */
    public boolean isExit(String fieldName, String value,String ObjectType){
        return deviceObjectRelateDao.isExit(fieldName, value,ObjectType);
    }

    /**
     * 描述 删除.
     *
     * @param deviceId the device id
     * @param objectId the object id
     * @author wenzhao.lin
     * @created 2021 -09-08 17:44:01 Delete by id.
     */
    public void deleteById(Integer deviceId, Integer objectId){
        deviceObjectRelateDao.deleteById(deviceId, objectId);
    }

    public void currRelationToLocal(){
        deviceObjectRelateDao.currRelationToLocal();
    }
}
